//
//  LJMListenSub_TableViewCell.m
//  wind
//
//  Created by 李金明 on 16/1/11.
//  Copyright © 2016年 李金明. All rights reserved.
//

#import "LJMListenSub_TableViewCell.h"
//numlab的坐标
#define NUMLABLEFT 15
#define NUMLABWIDTH 20
#define NUMLABHEIGHT 30
//titleImageV的坐标
#define TITLEIMAGEVHEIGHT 80
#define TITLEIMAGEVWIDTH 70
//titleLaber的坐标
#define TITLELABERRIGHT 60

@interface LJMListenSub_TableViewCell ()
@property (nonatomic, assign) CGFloat width;
@end

@implementation LJMListenSub_TableViewCell
- (void)dealloc
{
    [_sonerStr release];
    [_numLab release];
    [_titleImageV release];
    [_titleLab release];
    [_sonerLab release];
    [_listenerNumberLab release];
    [super dealloc];
}
- (void)setSonerStr:(NSString *)sonerStr
{
    if (_sonerStr != sonerStr) {
        [_sonerStr release];
        _sonerStr = [sonerStr retain];
    }
    self.width = [LJMAdaption_Height_Width widthWithStr:sonerStr NSInter:13.0];

    [self.sonerLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLab.mas_bottom);
        make.left.equalTo(self.titleLab.mas_left);
        make.width.mas_equalTo(self.width);
        make.bottom.equalTo(self.mas_bottom);
    }];
//    self.listenerNumberLab.frame = CGRectMake(self.sonerLab.frame.origin.x + self.sonerLab.frame.size.width, self.sonerLab.frame.origin.y, self.titleLab.bounds.size.width - self.sonerLab.bounds.size.width, self.sonerLab.bounds.size.height);
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatView];
    }
    return self;
}
- (void)creatView
{
    self.backgroundColor = [UIColor whiteColor];
    self.numLab = [[UILabel alloc] init];
    self.numLab.backgroundColor = [UIColor clearColor];
    self.numLab.textColor = [UIColor blackColor];
    [self.contentView addSubview:self.numLab];
    [_numLab release];
    
    self.titleImageV = [[UIImageView alloc] init];
    self.titleImageV.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.titleImageV];
    [_titleImageV release];
    
    self.titleLab = [[UILabel alloc] init];
    self.titleLab.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.titleLab];
    [_titleLab release];
    
    self.sonerLab = [[UILabel alloc] init];
    self.sonerLab.backgroundColor = [UIColor clearColor];
    self.sonerLab.font = [UIFont systemFontOfSize:12];
    self.sonerLab.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.sonerLab];
    [_sonerLab release];
    
//    self.listenerNumberLab = [[UILabel alloc] init];
//    self.listenerNumberLab.backgroundColor = [UIColor yellowColor];
//    self.listenerNumberLab.font = [UIFont systemFontOfSize:12];
//    [self.contentView addSubview:self.listenerNumberLab];
//    [_listenerNumberLab release];
}
- (void)layoutSubviews
{
[self.numLab mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(self);
    make.left.equalTo(self.mas_left).offset(NUMLABLEFT);
    make.width.equalTo(@NUMLABWIDTH);
    make.height.equalTo(@NUMLABHEIGHT);
}];
    [self.titleImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.height.equalTo(@TITLEIMAGEVHEIGHT);
        make.width.equalTo(@TITLEIMAGEVWIDTH);
        make.left.equalTo(self.numLab.mas_right).offset(NUMLABLEFT);
    }];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleImageV.mas_top);
        make.left.equalTo(self.titleImageV.mas_right).offset(NUMLABLEFT);
        make.height.mas_equalTo(@NUMLABLEFT);
        make.right.equalTo(self.mas_right).offset(-TITLELABERRIGHT);
    }];

}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
